import React, {Component} from 'react';
import './index.less';
import {base} from 'nc-lightapp-front';
import saveDieProcData from "./functions/saveBlacklistData";

const {NCModal, NCButton, NCTextArea} = base;
const {Header: NCModalHeader, Body: NCModalBody, Footer: NCModalFooter} = NCModal;

class BlacklistModal extends Component {
    constructor(props) {
        super(props);
        this.state = {
            addReason: ''
        };
        this.getEditInitInfo = this.getEditInitInfo.bind(this);
        this.closeModal = this.closeModal.bind(this);
        this.beSure = this.beSure.bind(this);
    }

    getEditInitInfo() {
        this.setState({
            addReason: ''
        })
    }

    beSure() {
        saveDieProcData.call(this);
    }

    closeModal() {
        this.setState({
            addReason: ''
        });
        this.props.onClose && this.props.onClose();
    }

    render() {
        const {visible} = this.props;
        return (
            <NCModal
                show={visible}
                size="sm"
                onHide={this.closeModal}
                onEntered={this.getEditInitInfo}
                backdrop={'static'}
            >
                <NCModalHeader
                    closeButton={true}
                >
                    {this.props.json['hi6007-000133']}{/* 国际化处理： 加入黑名单*/}
                </NCModalHeader>
                <NCModalBody>
                    <div>{this.props.json['hi6007-000134']}</div>{/* 国际化处理： 请填写加入原因*/}
                    <div>
                        <NCTextArea
                            value={this.state.addReason}
                            onChange={(value) => this.setState({
                                addReason: value
                            })}
                        />
                    </div>
                </NCModalBody>
                <NCModalFooter>
                    <NCButton
                        colors="primary"
                        onClick={this.beSure}
                    >
                        {this.props.json['hi6007-000174']}{/* 国际化处理： 确认*/}
                    </NCButton>
                    <NCButton
                        shape="border"
                        onClick={this.closeModal}
                    >
                        {this.props.json['hi6007-000005']}{/* 国际化处理： 取消*/}
                    </NCButton>
                </NCModalFooter>
            </NCModal>
        );
    }
}

export default BlacklistModal;
